package com.xnyzc.lhy.mis.service.impl.cms.userinfo;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xnyzc.lhy.common.component.convert.DateToStringConverter;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.penum.cms.EDriverType;
import com.xnyzc.lhy.common.penum.dept.EOffIceType;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.IDUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.mis.entity.result.user.UserLoginResult;
import com.xnyzc.lhy.mis.entity.sidebar.OaCUserOffice;
import com.xnyzc.lhy.mis.entity.sidebar.OaSysOffice;
import com.xnyzc.lhy.mis.entity.sidebar.OaSysSidebar;
import com.xnyzc.lhy.mis.entity.user.OaCUser;
import com.xnyzc.lhy.mis.entity.user.OaCUserInfo;
import com.xnyzc.lhy.mis.entity.user.UserInfoManage;
import com.xnyzc.lhy.mis.entity.user.tab.OaTabUser;
import com.xnyzc.lhy.mis.entity.user.wallet.OaCWallet;
import com.xnyzc.lhy.mis.mapper.sidebar.OaCUserOfficeMapper;
import com.xnyzc.lhy.mis.mapper.sidebar.OaSysOfficeMapper;
import com.xnyzc.lhy.mis.mapper.sidebar.OaSysSidebarMapper;
import com.xnyzc.lhy.mis.mapper.user.OaCUserInfoMapper;
import com.xnyzc.lhy.mis.mapper.user.OaCUserMapper;
import com.xnyzc.lhy.mis.mapper.user.tab.OaTabUserMapper;
import com.xnyzc.lhy.mis.mapper.user.wallet.OaCWalletMapper;
import com.xnyzc.lhy.mis.service.cms.userinfo.UserInfoManageService;
import com.xnyzc.lhy.mis.service.cms.util.IOaSysGetOfficeIdListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;

/**
 * 用户信息管理接口实现类
 *
 * @author zhaolijie
 * @date:2019/08/27
 */
@Service
public class UserInfoManageServiceImpl implements UserInfoManageService {

    @Autowired
    private IOaSysGetOfficeIdListService oaSysGetOfficeIdListService;


    @Autowired
    private OaCUserMapper oaCUserMapper;

    @Autowired
    private OaSysOfficeMapper oaSysOfficeMapper;

    @Autowired
    private OaCUserInfoMapper oaCUserInfoMapper;

    @Autowired
    private OaCUserOfficeMapper oaCUserOfficeMapper;

    @Autowired
    private OaCWalletMapper oaCWalletMapper;

    @Autowired
    private OaTabUserMapper oaTabUserMapper;

    @Autowired
    private OaSysSidebarMapper oaSysSidebarMapper;


    /**
     * 分页获取用户信息
     *
     * @param current：当前页
     * @return
     */
    @Override
    public Rv getUserInfo(Integer current) {
        List<OaSysOffice> oaSysOffice = this.findOaSysOffice();
        IPage iPage = new Page();
        iPage.setSize(20);
        iPage.setCurrent(current);
        List<Long> selectCUserIdList = oaSysGetOfficeIdListService.selectCUserIdList(TokenUtil.getTokenUserId(), TokenUtil.getRoleDataScope());
        if (selectCUserIdList.size() != 0) {
            //查询用户信息数据
            List<UserInfoManage> userInfo = oaCUserMapper.getUserInfo(iPage, selectCUserIdList);
            //根据用户的office_id查询
            List<UserInfoManage> userInfoManages = dataSplicing(userInfo, oaSysOffice);
            iPage.setRecords(userInfoManages);
        } else {
            iPage.setRecords(selectCUserIdList);
        }

        return Rv.wrap(EErrorCode.success, iPage);
    }

    /**
     * 模糊查询获取用户信息
     *
     * @param current:需要查询的页码
     * @param sex:性别,1：男，2：女，3：保密,4:未设置
     * @param isBlocked:0:正常用户;1:黑名单用户;2:用户已注销
     * @param userPhone:手机号码
     * @param userName:用户姓名
     * @return
     */
    @Override
    public Rv getUserInfoLike(Integer current, String sex, String isBlocked, String userPhone, String userName, String officeId) {
        List<OaSysOffice> oaSysOffice = this.findOaSysOffice();
        IPage iPage = new Page();
        iPage.setSize(20);
        iPage.setCurrent(current);
        List<Long> selectCUserIdList = oaSysGetOfficeIdListService.selectCUserIdList(TokenUtil.getTokenUserId(), TokenUtil.getRoleDataScope());
        List<Long> officeIds = oaSysGetOfficeIdListService.selectOfficeIdList(TokenUtil.getTokenUserId());
        List<OaSysOffice> offices = oaSysOfficeMapper.selectList(
                Wrappers.<OaSysOffice>lambdaQuery()
                        .eq(OaSysOffice::getTag, TokenUtil.getTag())
                        .eq(OaSysOffice::getParentId, officeId)
                        .in(OaSysOffice::getOfficeId, officeIds));
        //查询用户信息数据
        List<UserInfoManage> userInfoLike;
        // 公司
        if (offices.size() > 0){
            // 公司下所有部门
            List<Long> ids = new ArrayList<>();
            for (OaSysOffice office : offices) {
                if (EOffIceType.dept.getValue().equals(office.getType())){
                    ids.add(office.getOfficeId());
                }
            }
            if (CheckUtil.objIsEmpty(ids)){
                ids.add(-1L);
            }
            //查询用户信息数据
            userInfoLike = oaCUserMapper.getUserInfoLike(iPage, selectCUserIdList, sex, isBlocked, userPhone, userName, null, ids);
        }
        // 部门
        else {
            //查询用户信息数据
            userInfoLike = oaCUserMapper.getUserInfoLike(iPage, selectCUserIdList, sex, isBlocked, userPhone, userName, officeId, null);
        }
        //根据用户的office_id查询
        List<UserInfoManage> userInfoManages = dataSplicing(userInfoLike, oaSysOffice);
        iPage.setRecords(userInfoManages);
        return Rv.wrap(EErrorCode.success, iPage);
    }

    /**
     * 获取数据导出Excel数据
     *
     * @return
     */
    @Override
    public Rv exportExcelUserInfo() {
        List<OaSysOffice> oaSysOffice = this.findOaSysOffice();
        List<Long> selectCUserIdList = oaSysGetOfficeIdListService.selectCUserIdList(TokenUtil.getTokenUserId(), TokenUtil.getRoleDataScope());
        //查询用户信息数据
        List<UserInfoManage> userInfoManages = oaCUserMapper.exportExcelUserInfo(selectCUserIdList);
        //根据用户的office_id查询
        List<UserInfoManage> userInfoManagesResult = dataSplicing(userInfoManages, oaSysOffice);
        List<HashMap<String, Object>> hashMapList = new ArrayList<>();
        for (int i = 0; i < userInfoManagesResult.size(); i++) {
            HashMap<String, Object> result = new HashMap<>(userInfoManagesResult.size());
            result.put("userName", userInfoManagesResult.get(i).getUserName());
            result.put("identityNumber", userInfoManagesResult.get(i).getIdentityNumber());
            result.put("userPhone", userInfoManagesResult.get(i).getUserPhone());
            result.put("officeCode", userInfoManagesResult.get(i).getOfficeCode());
            result.put("address", userInfoManagesResult.get(i).getAddress());
            result.put("emergencyContact", userInfoManagesResult.get(i).getEmergencyContact());
            result.put("emergencyMobile", userInfoManagesResult.get(i).getEmergencyMobile());
            result.put("emergencyAddress", userInfoManagesResult.get(i).getEmergencyAddress());
            result.put("email", userInfoManagesResult.get(i).getEmail());
            if (null == userInfoManagesResult.get(i).getLoginAccount()) {
                result.put("loginAccount", "未设置");
            } else {
                result.put("loginAccount", userInfoManagesResult.get(i).getLoginAccount());
            }
            result.put("departmentsOfAttribution", userInfoManagesResult.get(i).getDepartmentsOfAttribution());
            result.put("ownershipCompany", userInfoManagesResult.get(i).getOwnershipCompany());
            if (userInfoManagesResult.get(i).getUserType() == 0) {
                result.put("userType", "个人");
            } else {
                result.put("userType", "企业");
            }
            result.put("isBlocked", EDriverType.findIsBlocked(userInfoManagesResult.get(i).getIsBlocked()).getDesc());
            result.put("sex", EDriverType.findSex(Integer.valueOf(userInfoManagesResult.get(i).getSex())).getDesc());
            result.put("createTime", new DateToStringConverter().convert(userInfoManagesResult.get(i).getCreateTime()));
            hashMapList.add(result);
        }
        return Rv.wrap(EErrorCode.success, hashMapList);
    }

    /**
     * 新增用户信息
     *
     * @param userInfoManage
     * @return
     */
    @Override
    public Rv addUserInfo(UserInfoManage userInfoManage) {
        //查询用户信息表
        QueryWrapper<OaCUserInfo> queryWrapperOaCUserInfo = new QueryWrapper<>();
        queryWrapperOaCUserInfo.eq(OaCUserInfo.IDENTITY_NUMBER, userInfoManage.getIdentityNumber());
        List<OaCUserInfo> oaCUserInfos = oaCUserInfoMapper.selectList(queryWrapperOaCUserInfo);
        //查询用户基础表
        QueryWrapper<OaCUser> queryWrapperOaCUser = new QueryWrapper<>();
        queryWrapperOaCUser.eq(OaCUser.USER_PHONE, userInfoManage.getUserPhone());
        List<OaCUser> oaCUsers = oaCUserMapper.selectList(queryWrapperOaCUser);
        if (oaCUsers.size() == 0 && oaCUserInfos.size() == 0) {
            String tag = TokenUtil.getTag();
            if (CheckUtil.objIsEmpty(tag)) {
                throw PangException.create(EErrorCode.missingAuthArgs);
            }
            UserLoginResult userLoginResult = (UserLoginResult) TokenUtil.getTokenUserEntity(UserLoginResult.class);
            QueryWrapper<OaSysOffice> queryWrapperOaSysOffice = new QueryWrapper<>();
            queryWrapperOaSysOffice.eq(OaSysOffice.OFFICE_ID, userLoginResult.getOfficeId());
            OaSysOffice oaSysOffice = oaSysOfficeMapper.selectOne(queryWrapperOaSysOffice);
            long userId = IDUtil.nextId();
            //用户基础表
            OaCUser oaCUser = new OaCUser();
            oaCUser.setUserId(userId);
            oaCUser.setUserPhone(userInfoManage.getUserPhone());
            oaCUser.setLoginAccount(userInfoManage.getLoginAccount());
            oaCUser.setLoginPassword(userInfoManage.getLoginPassword());
            oaCUser.setUserName(userInfoManage.getUserName());
            oaCUser.setSex(userInfoManage.getSex());
            oaCUser.setUserType(userInfoManage.getUserType());
            oaCUser.setCreateUser(TokenUtil.getTokenUserId());
            oaCUser.setCreateTime(new Date());
            oaCUser.setUpdateTime(new Date());
            oaCUser.setTag(tag);
            oaCUser.setAvatarFileId(userInfoManage.getAvatarFileId());
            //用户信息表
            OaCUserInfo oaCUserInfo = new OaCUserInfo();
            oaCUserInfo.setInfoId(IDUtil.nextId());
            oaCUserInfo.setUserId(userId);
            oaCUserInfo.setAge(userInfoManage.getAge());
            oaCUserInfo.setAddress(userInfoManage.getAddress());
            oaCUserInfo.setEmergencyContact(userInfoManage.getEmergencyContact());
            oaCUserInfo.setEmergencyMobile(userInfoManage.getEmergencyMobile());
            oaCUserInfo.setEmergencyAddress(userInfoManage.getEmergencyAddress());
            oaCUserInfo.setIdentityNumber(userInfoManage.getIdentityNumber());
            oaCUserInfo.setIdentityType(1);
            oaCUserInfo.setIdentityAddress(userInfoManage.getIdentityAddress());
            oaCUserInfo.setTag(tag);
            oaCUserInfo.setCreateUser(TokenUtil.getTokenUserId());
            oaCUserInfo.setUpdateTime(new Date());
            oaCUserInfo.setCreateTime(new Date());
            oaCUserInfo.setIdentityPositiveFileId(userInfoManage.getIdentityPositiveFileId());
            oaCUserInfo.setIdentityOtherFileId(userInfoManage.getIdentityOtherFileId());
            //乘客钱包表
            OaCWallet oaCWallet = new OaCWallet();
            oaCWallet.setWalletId(IDUtil.nextId());
            oaCWallet.setUserId(userId);
            oaCWallet.setWalletBalance(new BigDecimal(0));
            oaCWallet.setOfficeId(userLoginResult.getOfficeId());
            oaCWallet.setCreateUser(TokenUtil.getTokenUserId());
            oaCWallet.setCreateTime(new Date());
            oaCWallet.setCreateTime(new Date());
            oaCWallet.setUpdateTime(new Date());
            oaCWallet.setDeptOfficialBalance(new BigDecimal(0));
            oaCWallet.setPersonalOfficialBalance(new BigDecimal(0));
            oaCWallet.setTag(tag);

            //Tab权限关联表
            OaTabUser oaTabUser = new OaTabUser();
            oaTabUser.setLinkedId(IDUtil.nextId());
            oaTabUser.setUserId(userId);
            oaTabUser.setTabId(0);
            oaTabUser.setUserType(0);
            oaTabUser.setTag(tag);
            oaTabUser.setCreateUser(TokenUtil.getTokenUserId());
            oaTabUser.setCreateTime(new Date());
            oaTabUser.setUpdateTime(new Date());


            //侧边栏关联表
            OaSysSidebar oaSysSidebar = new OaSysSidebar();
            oaSysSidebar.setSidebarId(IDUtil.nextId());
            oaSysSidebar.setUserId(userId);
            oaSysSidebar.setDictIds("38,39,67");
            oaSysSidebar.setType("1");
            oaSysSidebar.setTag(tag);
            oaSysSidebar.setCreateUser(TokenUtil.getTokenUserId());
            oaSysSidebar.setCreateTime(new Date());
            oaSysSidebar.setUpdateTime(new Date());
            oaSysSidebar.setDictAssociatedIds("23,");
            oaSysSidebar.setHaveSpecifiedVehicle(0);

            oaCUserMapper.insert(oaCUser);
            oaCUserInfoMapper.insert(oaCUserInfo);

            oaCWalletMapper.insert(oaCWallet);
            oaTabUserMapper.insert(oaTabUser);
            oaSysSidebarMapper.insert(oaSysSidebar);

            // 新增用户部门关联
            this.insertOaCUserOffice(userId, userLoginResult, userInfoManage, tag);
            return Rv.wrap(EErrorCode.success);
        } else {
            return Rv.wrap(EErrorCode.beUsed.getValue());
        }
    }

    /**
     * 获取用户详情
     *
     * @param userId：用户ID
     * @return
     */
    @Override
    public Rv getUserInfoDetails(Long userId) {
        UserInfoManage userInfoDetails = oaCUserMapper.getUserInfoDetails(userId);
        return Rv.wrap(EErrorCode.success, userInfoDetails);
    }

    /**
     * 修改用户信息
     *
     * @param userInfoManage
     * @return
     */
    @Override
    public Rv updateUserInfo(UserInfoManage userInfoManage) {
        //查询用户基础表
        List<UserInfoManage> oaCUserPhone = oaCUserMapper.findOaCUserPhone(userInfoManage.getUserPhone(), userInfoManage.getUserId());
        //查询用户信息表
        QueryWrapper<OaCUserInfo> queryWrapperOaCUserInfo = new QueryWrapper<>();
        queryWrapperOaCUserInfo.ne(OaCUserInfo.INFO_ID, userInfoManage.getInfoId());
        queryWrapperOaCUserInfo.eq(OaCUserInfo.IDENTITY_NUMBER, userInfoManage.getIdentityNumber());
        List<OaCUserInfo> oaCUserInfos = oaCUserInfoMapper.selectList(queryWrapperOaCUserInfo);
        if (oaCUserPhone.size() == 0 && oaCUserInfos.size() == 0) {
            //用户基础表
            OaCUser oaCUser = new OaCUser();
            oaCUser.setUserId(userInfoManage.getUserId());
            oaCUser.setUserName(userInfoManage.getUserName());
            oaCUser.setSex(userInfoManage.getSex());
            oaCUser.setUserPhone(userInfoManage.getUserPhone());
            oaCUser.setLoginPassword(userInfoManage.getLoginPassword());
            oaCUser.setUserType(userInfoManage.getUserType());
            oaCUser.setUpdateTime(new Date());
            oaCUser.setUpdateUser(TokenUtil.getTokenUserId());
            oaCUser.setAvatarFileId(userInfoManage.getAvatarFileId());

            //用户信息表
            OaCUserInfo oaCUserInfo = new OaCUserInfo();
            oaCUserInfo.setInfoId(userInfoManage.getInfoId());
            oaCUserInfo.setAge(userInfoManage.getAge());
            oaCUserInfo.setIdentityNumber(userInfoManage.getIdentityNumber());
            oaCUserInfo.setAddress(userInfoManage.getAddress());
            oaCUserInfo.setEmergencyContact(userInfoManage.getEmergencyContact());
            oaCUserInfo.setEmergencyMobile(userInfoManage.getEmergencyMobile());
            oaCUserInfo.setEmergencyAddress(userInfoManage.getEmergencyAddress());
            oaCUserInfo.setIdentityAddress(userInfoManage.getIdentityAddress());
            oaCUserInfo.setUpdateUser(TokenUtil.getTokenUserId());
            oaCUserInfo.setUpdateTime(new Date());
            oaCUserInfo.setIdentityPositiveFileId(userInfoManage.getIdentityPositiveFileId());
            oaCUserInfo.setIdentityOtherFileId(userInfoManage.getIdentityOtherFileId());

            oaCUserMapper.updateById(oaCUser);
            oaCUserInfoMapper.updateById(oaCUserInfo);
            // 修改部门
            Date date = new Date();
            Long sysUserId = TokenUtil.getTokenUserId();
            String tag = TokenUtil.getTag();
            Long userId = userInfoManage.getUserId();
            List<OaCUserOffice> oaCUserOfficeList = oaCUserOfficeMapper.selectList(Wrappers.<OaCUserOffice>lambdaQuery().eq(OaCUserOffice::getTag, tag).eq(OaCUserOffice::getUserId, userId));
            if (oaCUserOfficeList.size() == 1){
                OaCUserOffice oaCUserOffice = oaCUserOfficeList.get(0);
                String officeId = userInfoManage.getOfficeId();
                if (CheckUtil.objIsNotEmpty(officeId, oaCUserOffice.getOfficeId())){
                    if (!officeId.equals(oaCUserOffice.getOfficeId().toString())){
                        oaCUserOffice.setUpdateTime(date);
                        oaCUserOffice.setUpdateUser(sysUserId);
                        oaCUserOffice.setOfficeId(Long.valueOf(officeId));
                        oaCUserOfficeMapper.updateById(oaCUserOffice);
                    }
                }
            }
            return Rv.wrap(EErrorCode.success);
        } else {
            return Rv.wrap(EErrorCode.beUsed.getValue());
        }
    }

    /**
     * 获取部门信息
     *
     * @return
     */
    @Override
    public Rv getOfficeInfo() {
        //查询父信息
        QueryWrapper<OaSysOffice> queryWrapperGroup = new QueryWrapper<>();
        queryWrapperGroup.eq(OaSysOffice.PARENT_ID, 1);
        List<Map<String, Object>> queryWrapperGroupList = oaSysOfficeMapper.selectMaps(queryWrapperGroup);
        //查询子信息
        QueryWrapper<OaSysOffice> queryWrapperChild = new QueryWrapper<>();
        queryWrapperChild.ne(OaSysOffice.PARENT_ID, 1);
        queryWrapperChild.ne(OaSysOffice.PARENT_ID, 0);
        List<Map<String, Object>> queryWrapperChildList = oaSysOfficeMapper.selectMaps(queryWrapperChild);
        List<Map<String, Object>> brandCarSystemSplicing = this.brandCarSystemSplicing(queryWrapperGroupList, queryWrapperChildList);
        return Rv.wrap(EErrorCode.success, brandCarSystemSplicing);
    }

    /**
     * 机构数据拼接
     */
    public List<Map<String, Object>> brandCarSystemSplicing(List<Map<String, Object>> queryWrapperGroup, List<Map<String, Object>> oaSysVehicleMdictsChild) {
        // 将拼接完毕的菜单放入resultList返回
        List<Map<String, Object>> resultList = new ArrayList<>();
        //开始拼接菜单，如果父菜单的id和子菜单的pId相等，证明其是父子关系，在父菜单后追加即可
        for (int i = 0; i < queryWrapperGroup.size(); i++) {
            Map<String, Object> groupMap = queryWrapperGroup.get(i);
            List<Map<String, Object>> child_list = new ArrayList<>();
            groupMap.put("label", groupMap.get("name"));
            groupMap.put("value", groupMap.get("office_id"));
            for (int j = 0; j < oaSysVehicleMdictsChild.size(); j++) {
                Map<String, Object> childMap = oaSysVehicleMdictsChild.get(j);
                if (String.valueOf(groupMap.get("office_id")).equals(childMap.get("parent_id"))) {
                    child_list.add(childMap);
                }
                childMap.put("label", childMap.get("name"));
                childMap.put("value", childMap.get("office_id"));
            }
            groupMap.put("children", child_list);
            resultList.add(groupMap);
        }
        return resultList;
    }


    /**
     * 查询机构字典
     *
     * @return
     */
    private List<OaSysOffice> findOaSysOffice() {
        //查询机构字典数据
        QueryWrapper<OaSysOffice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(OaSysOffice.DELETED, 0);
        return oaSysOfficeMapper.selectList(queryWrapper);
    }


    /**
     * 数据拼接表格
     *
     * @param userInfoManageList:用户List
     * @param oaSysOfficeList：字典List
     * @return
     */
    private List<UserInfoManage> dataSplicing(List<UserInfoManage> userInfoManageList, List<OaSysOffice> oaSysOfficeList) {
        for (int i = 0; i < userInfoManageList.size(); i++) {
            for (int j = 0; j < oaSysOfficeList.size(); j++) {
                if (userInfoManageList.get(i).getOfficeId().equals(String.valueOf(oaSysOfficeList.get(j).getOfficeId()))) {
                    userInfoManageList.get(i).setDepartmentsOfAttribution(oaSysOfficeList.get(j).getName());
                    userInfoManageList.get(i).setOfficeCode(oaSysOfficeList.get(j).getCode());
                    for (int k = 0; k < oaSysOfficeList.size(); k++) {
                        if (String.valueOf(oaSysOfficeList.get(k).getOfficeId()).equals(oaSysOfficeList.get(j).getParentId())) {
                            userInfoManageList.get(i).setOwnershipCompany(oaSysOfficeList.get(k).getName());
                        }
                    }
                }
            }
        }
        return userInfoManageList;
    }

    /**
     * 新增用户部门关联
     * @param userId 用户id
     * @param userLoginResult 后台用户信息实体
     * @param userInfoManage 入参实体
     * @param tag 用户来源
     */
    private void insertOaCUserOffice(Long userId, UserLoginResult userLoginResult, UserInfoManage userInfoManage, String tag){
        Long sysUserId = TokenUtil.getTokenUserId();
        Date date = new Date();
        //用户机构关联表
        OaCUserOffice oaCUserOffice = new OaCUserOffice();
        oaCUserOffice.setLinkedId(IDUtil.nextId());
        oaCUserOffice.setUserId(userId);
        oaCUserOffice.setTag(tag);
        oaCUserOffice.setCreateUser(sysUserId);
        oaCUserOffice.setCreateTime(date);
        oaCUserOffice.setUpdateUser(sysUserId);
        oaCUserOffice.setUpdateTime(date);
        String officeId = userInfoManage.getOfficeId();
        if (CheckUtil.objIsEmpty(officeId)){
            oaCUserOffice.setOfficeId(userLoginResult.getOfficeId());
        } else {
            oaCUserOffice.setOfficeId(Long.valueOf(officeId));
        }
        oaCUserOfficeMapper.insert(oaCUserOffice);
    }
}
